
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>从静态视图首次渲染开始 · petite-vue源码剖析</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="^_^肥仔John">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="2_initial_rendering_and_rerendering_for_v-if.html" />
    
    
    <link rel="prev" href="0_intro.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">前言</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    《Petite-Vue源码剖析》简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../0_intro/1_reason_for_source_reading.html">
            
                <a href="../0_intro/1_reason_for_source_reading.html">
            
                    
                    为什么要读源码
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">在线渲染</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="0_intro.html">
            
                <a href="0_intro.html">
            
                    
                    章节介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.2" data-path="1_start_from_static_view.html">
            
                <a href="1_start_from_static_view.html">
            
                    
                    从静态视图首次渲染开始
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="2_initial_rendering_and_rerendering_for_v-if.html">
            
                <a href="2_initial_rendering_and_rerendering_for_v-if.html">
            
                    
                    条件v-if的首次渲染和重新渲染
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="3_initial_rendering_and_rerendering_for_v-for.html">
            
                <a href="3_initial_rendering_and_rerendering_for_v-for.html">
            
                    
                    循环v-for的首次渲染和重新渲染
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="4_directives/1_attribute_binding.html">
            
                <a href="4_directives/1_attribute_binding.html">
            
                    
                    属性绑定v-bind的工作原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="4_directives/2_event_binding.html">
            
                <a href="4_directives/2_event_binding.html">
            
                    
                    事件绑定v-on的工作原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="4_directives/3_bidirectional_binding.html">
            
                <a href="4_directives/3_bidirectional_binding.html">
            
                    
                    双向绑定v-model的工作原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="4_directives/4_ref.html">
            
                <a href="4_directives/4_ref.html">
            
                    
                    特殊指令ref的工作原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="5_tips_for_template.html">
            
                <a href="5_tips_for_template.html">
            
                    
                    优化手段template的原理和使用技巧
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">响应式系统</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../2_reactivity_system/0_intro.html">
            
                <a href="../2_reactivity_system/0_intro.html">
            
                    
                    章节介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../2_reactivity_system/1_reactive_object_array.html">
            
                <a href="../2_reactivity_system/1_reactive_object_array.html">
            
                    
                    逐行解读reactive如何构建对象和数组的响应式对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../2_reactivity_system/2_reactive_map_set.html">
            
                <a href="../2_reactivity_system/2_reactive_map_set.html">
            
                    
                    逐行解读reactive如何构建Map和Set的响应式对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../2_reactivity_system/3_register_side_effect.html">
            
                <a href="../2_reactivity_system/3_register_side_effect.html">
            
                    
                    逐行解读effect如何注册副作用函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../2_reactivity_system/4_cleanup_algorithm.html">
            
                <a href="../2_reactivity_system/4_cleanup_algorithm.html">
            
                    
                    依赖清理优化算法详解-算法思路
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../2_reactivity_system/5_smi.html">
            
                <a href="../2_reactivity_system/5_smi.html">
            
                    
                    依赖清理优化算法详解-基于JavaScript引擎的SMI进一步压榨性能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../2_reactivity_system/6_trigger_and_scheduler.html">
            
                <a href="../2_reactivity_system/6_trigger_and_scheduler.html">
            
                    
                    逐行解读trigger和调度器
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">沙箱模型</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../3_sandbox.html">
            
                <a href="../3_sandbox.html">
            
                    
                    模板表达式的沙箱模型
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >从静态视图首次渲染开始</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x4ECE;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x9996;&#x6B21;&#x6E32;&#x67D3;&#x5F00;&#x59CB;"><b>1. </b>&#x4ECE;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x9996;&#x6B21;&#x6E32;&#x67D3;&#x5F00;&#x59CB;</a></li><ul><li><span class="title-icon "></span><a href="#&#x4EE3;&#x7801;&#x5E93;&#x7ED3;&#x6784;&#x4ECB;&#x7ECD;"><b>1.1. </b>&#x4EE3;&#x7801;&#x5E93;&#x7ED3;&#x6784;&#x4ECB;&#x7ECD;</a></li><li><span class="title-icon "></span><a href="#&#x6DF1;&#x5165;&#x7406;&#x89E3;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x7684;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;"><b>1.2. </b>&#x6DF1;&#x5165;&#x7406;&#x89E3;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x7684;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;</a></li><ul><li><span class="title-icon "></span><a href="#&#x4F5C;&#x7528;&#x57DF;scope"><b>1.2.1. </b>&#x4F5C;&#x7528;&#x57DF;(scope)</a></li><li><span class="title-icon "></span><a href="#&#x5757;&#x5BF9;&#x8C61;block"><b>1.2.2. </b>&#x5757;&#x5BF9;&#x8C61;(block)</a></li><li><span class="title-icon "></span><a href="#&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;context"><b>1.2.3. </b>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</a></li></ul><li><span class="title-icon "></span><a href="#&#x4EBA;&#x8089;&#x5355;&#x6B65;&#x8C03;&#x8BD5;"><b>1.3. </b>&#x4EBA;&#x8089;&#x5355;&#x6B65;&#x8C03;&#x8BD5;</a></li><li><span class="title-icon "></span><a href="#&#x5C0F;&#x7ED3;"><b>1.4. </b>&#x5C0F;&#x7ED3;</a></li></ul></ul></div><h1 id="&#x4ECE;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x9996;&#x6B21;&#x6E32;&#x67D3;&#x5F00;&#x59CB;"><a name="&#x4ECE;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x9996;&#x6B21;&#x6E32;&#x67D3;&#x5F00;&#x59CB;" class="anchor-navigation-ex-anchor" href="#&#x4ECE;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x9996;&#x6B21;&#x6E32;&#x67D3;&#x5F00;&#x59CB;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x4ECE;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x9996;&#x6B21;&#x6E32;&#x67D3;&#x5F00;&#x59CB;</h1>
<h2 id="&#x4EE3;&#x7801;&#x5E93;&#x7ED3;&#x6784;&#x4ECB;&#x7ECD;"><a name="&#x4EE3;&#x7801;&#x5E93;&#x7ED3;&#x6784;&#x4ECB;&#x7ECD;" class="anchor-navigation-ex-anchor" href="#&#x4EE3;&#x7801;&#x5E93;&#x7ED3;&#x6784;&#x4ECB;&#x7ECD;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. &#x4EE3;&#x7801;&#x5E93;&#x7ED3;&#x6784;&#x4ECB;&#x7ECD;</h2>
<ul>
<li>examples &#x5404;&#x79CD;&#x4F7F;&#x7528;&#x793A;&#x4F8B;</li>
<li>scripts &#x6253;&#x5305;&#x53D1;&#x5E03;&#x811A;&#x672C;</li>
<li>tests &#x6D4B;&#x8BD5;&#x7528;&#x4F8B;</li>
<li>src<ul>
<li>directives <code>v-if</code>&#x7B49;&#x5185;&#x7F6E;&#x6307;&#x4EE4;&#x7684;&#x5B9E;&#x73B0;</li>
<li>app.ts <code>createApp</code>&#x51FD;&#x6570;</li>
<li>block.ts &#x5757;&#x5BF9;&#x8C61;</li>
<li>context.ts &#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;</li>
<li>eval.ts &#x63D0;&#x4F9B;<code>v-if=&quot;count === 1&quot;</code>&#x7B49;&#x8868;&#x8FBE;&#x5F0F;&#x8FD0;&#x7B97;&#x529F;&#x80FD;</li>
<li>scheduler.ts &#x8C03;&#x5EA6;&#x5668;</li>
<li>utils.ts &#x5DE5;&#x5177;&#x51FD;&#x6570;</li>
<li>walk.ts &#x6A21;&#x677F;&#x89E3;&#x6790;</li>
</ul>
</li>
</ul>
<p>&#x82E5;&#x60F3;&#x6784;&#x5EFA;&#x81EA;&#x5DF1;&#x7684;&#x7248;&#x672C;&#x53EA;&#x9700;&#x5728;&#x63A7;&#x5236;&#x53F0;&#x6267;&#x884C;<code>npm run build</code>&#x5373;&#x53EF;&#x3002;</p>
<h2 id="&#x6DF1;&#x5165;&#x7406;&#x89E3;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x7684;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;"><a name="&#x6DF1;&#x5165;&#x7406;&#x89E3;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x7684;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;" class="anchor-navigation-ex-anchor" href="#&#x6DF1;&#x5165;&#x7406;&#x89E3;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x7684;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. &#x6DF1;&#x5165;&#x7406;&#x89E3;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x7684;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;</h2>
<p>&#x9759;&#x6001;&#x89C6;&#x56FE;&#x662F;&#x6307;&#x9996;&#x6B21;&#x6E32;&#x67D3;&#x540E;&#xFF0C;&#x4E0D;&#x4F1A;&#x56E0;UI&#x72B6;&#x6001;&#x53D8;&#x5316;&#x5F15;&#x53D1;&#x91CD;&#x65B0;&#x6E32;&#x67D3;&#x3002;&#x5176;&#x4E2D;<em>&#x89C6;&#x56FE;&#x4E0D;&#x5305;&#x542B;&#x4EFB;&#x4F55;UI&#x72B6;&#x6001;</em>&#xFF0C;&#x548C;<em>&#x6839;&#x636E;UI&#x72B6;&#x6001;&#x9996;&#x6B21;&#x6E32;&#x67D3;&#x540E;&#x72B6;&#x6001;&#x4E0D;&#x518D;&#x66F4;&#x65B0;</em>&#x4E24;&#x79CD;&#x60C5;&#x51B5;&#xFF0C;&#x672C;&#x7BC7;&#x5C06;&#x9488;&#x5BF9;&#x524D;&#x8005;&#x8FDB;&#x884C;&#x8BB2;&#x89E3;&#x3002;</p>
<p>&#x793A;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">v-scope</span>=<span class="hljs-string">&quot;App&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;module&quot;</span>&gt;</span><span class="handlebars"><span class="xml">
  import { createApp } from &apos;https://unpkg.com/petite-vue?module&apos;

  createApp({
    App: {
      $template: `
      <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span> OFFLINE <span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span> UNKNOWN <span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span> ONLINE <span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
      `
    }
  }).mount(&apos;[v-scope]&apos;)
</span></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>&#x9996;&#x5148;&#x8FDB;&#x5165;&#x7684;&#x5C31;&#x662F;<code>createApp</code>&#x65B9;&#x6CD5;&#xFF0C;&#x5B83;&#x7684;&#x4F5C;&#x7528;&#x5C31;&#x662F;&#x521B;&#x5EFA;<em>&#x6839;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(root context)</em>&#x3001;<em>&#x5168;&#x5C40;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;(root scope)</em>&#x5E76;&#x8FD4;&#x56DE;<code>mount</code>,<code>unmount</code>&#x548C;<code>directive</code>&#x65B9;&#x6CD5;&#x3002;&#x7136;&#x540E;&#x901A;&#x8FC7;<code>mount</code>&#x65B9;&#x6CD5;&#x5BFB;&#x627E;&#x9644;&#x5E26;<code>[v-scope]</code>&#x5C5E;&#x6027;&#x7684;&#x5B69;&#x5B50;&#x8282;&#x70B9;&#xFF08;&#x6392;&#x9664;&#x5339;&#x914D;<code>[v-scope] [v-scope]</code>&#x7684;&#x5B50;&#x5B59;&#x8282;&#x70B9;&#xFF09;&#xFF0C;&#x5E76;&#x4E3A;&#x5B83;&#x4EEC;&#x521B;&#x5EFA;<em>&#x6839;&#x5757;&#x5BF9;&#x8C61;</em>&#x3002;
&#x6E90;&#x7801;&#x5982;&#x4E0B;&#xFF08;&#x57FA;&#x4E8E;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x6211;&#x5BF9;&#x6E90;&#x7801;&#x8FDB;&#x884C;&#x90E8;&#x5206;&#x5220;&#x51CF;&#x4EE5;&#x4FBF;&#x66F4;&#x5BB9;&#x6613;&#x9605;&#x8BFB;&#xFF09;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-comment">// &#x6587;&#x4EF6; ./src/app.ts</span>

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> createApp = (initialData: <span class="hljs-built_in">any</span>) =&gt; {
  <span class="hljs-comment">// &#x521B;&#x5EFA;&#x6839;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;</span>
  <span class="hljs-keyword">const</span> ctx = createContext()
  <span class="hljs-comment">// &#x5168;&#x5C40;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;&#xFF0C;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x54CD;&#x5E94;&#x5F0F;&#x5BF9;&#x8C61;</span>
  ctx.scope = reactive(initialData)
  <span class="hljs-comment">/* &#x5C06;scope&#x7684;&#x51FD;&#x6570;&#x6210;&#x5458;&#x7684;this&#x5747;&#x7ED1;&#x5B9A;&#x4E3A;scope&#x3002;
   * &#x82E5;&#x91C7;&#x7528;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x8D4B;&#x503C;&#x7ED9;&#x51FD;&#x6570;&#x6210;&#x5458;&#xFF0C;&#x5219;&#x4E0A;&#x8FF0;&#x64CD;&#x4F5C;&#x5BF9;&#x8BE5;&#x51FD;&#x6570;&#x6210;&#x5458;&#x65E0;&#x6548;&#x3002;
   */</span>
  bindContextMethods(ctx.scope)

  <span class="hljs-comment">/* &#x6839;&#x5757;&#x5BF9;&#x8C61;&#x96C6;&#x5408;
   * petite-vue&#x652F;&#x6301;&#x591A;&#x4E2A;&#x6839;&#x5757;&#x5BF9;&#x8C61;&#xFF0C;&#x4F46;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7B80;&#x5316;&#x4E3A;&#x4EC5;&#x652F;&#x6301;&#x4E00;&#x4E2A;&#x6839;&#x5757;&#x5BF9;&#x8C61;&#x3002;
   */</span>
  <span class="hljs-keyword">let</span> rootBlocks: Block[]

  <span class="hljs-keyword">return</span> {
    <span class="hljs-comment">// &#x7B80;&#x5316;&#x4E3A;&#x5FC5;&#x5B9A;&#x6302;&#x8F7D;&#x5230;&#x67D0;&#x4E2A;&#x5E26;`[v-scope]`&#x7684;&#x5143;&#x7D20;&#x4E0B;</span>
    mount(el: Element) {
      <span class="hljs-keyword">let</span> roots = el.hasAttribute(<span class="hljs-string">&apos;v-scope&apos;</span>) ? [el] : []
      <span class="hljs-comment">// &#x521B;&#x5EFA;&#x6839;&#x5757;&#x5BF9;&#x8C61;</span>
      rootBlocks = roots.map(el =&gt; <span class="hljs-keyword">new</span> Block(el, ctx, <span class="hljs-literal">true</span>))
      <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>
    },
    unmount() {
      <span class="hljs-comment">// &#x5F53;&#x8282;&#x70B9;&#x5378;&#x8F7D;&#x65F6;(removeChild)&#x6267;&#x884C;&#x5757;&#x5BF9;&#x8C61;&#x7684;&#x6E05;&#x7406;&#x5DE5;&#x4F5C;&#x3002;&#x6CE8;&#x610F;&#xFF1A;&#x5237;&#x65B0;&#x754C;&#x9762;&#x65F6;&#x4E0D;&#x4F1A;&#x89E6;&#x53D1;&#x8BE5;&#x64CD;&#x4F5C;&#x3002;</span>
      rootBlocks.forEach(block =&gt; block.teardown())
    }
  }
}
</code></pre>
<p>&#x4EE3;&#x7801;&#x867D;&#x7136;&#x5F88;&#x77ED;&#xFF0C;&#x4F46;&#x5F15;&#x51FA;&#x4E86;3&#x4E2A;&#x6838;&#x5FC3;&#x5BF9;&#x8C61;&#xFF1A;<em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em>&#x3001;<em>&#x4F5C;&#x7528;&#x57DF;(scope)</em>&#x548C;<em>&#x5757;&#x5BF9;&#x8C61;(block)</em>&#x3002;&#x4ED6;&#x4EEC;&#x4E09;&#x7684;&#x5173;&#x7CFB;&#x662F;&#xFF1A;</p>
<ul>
<li><em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em> &#x548C; <em>&#x4F5C;&#x7528;&#x57DF;(scope)</em> &#x662F; 1 &#x5BF9; 1 &#x5173;&#x7CFB;&#xFF1B;</li>
<li><em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em> &#x548C; <em>&#x5757;&#x5BF9;&#x8C61;(block)</em> &#x662F; &#x591A; &#x5BF9; &#x591A; &#x5173;&#x7CFB;&#xFF0C;&#x5176;&#x4E2D;<em>&#x5757;&#x5BF9;&#x8C61;(block)</em>&#x901A;&#x8FC7;<code>ctx</code>&#x6307;&#x5411;&#x5F53;&#x524D;<em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em>&#xFF0C;&#x5E76;&#x901A;&#x8FC7;<code>parentCtx</code>&#x6307;&#x5411;&#x7236;<em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em>&#xFF1B;</li>
<li><em>&#x4F5C;&#x7528;&#x57DF;(scope)</em> &#x548C; <em>&#x5757;&#x5BF9;&#x8C61;(block)</em> &#x662F; 1 &#x5BF9; &#x591A; &#x5173;&#x7CFB;&#x3002;</li>
</ul>
<p>&#x5177;&#x4F53;&#x7ED3;&#x8BBA;&#x662F;:</p>
<ul>
<li><em>&#x6839;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em> &#x53EF;&#x88AB;&#x591A;&#x4E2A;<em>&#x6839;&#x5757;&#x5BF9;&#x8C61;</em>&#x901A;&#x8FC7;<code>ctx</code>&#x5F15;&#x7528;&#xFF1B;</li>
<li><em>&#x5757;&#x5BF9;&#x8C61;(block)</em>&#x521B;&#x5EFA;&#x65F6;&#x4F1A;&#x57FA;&#x4E8E;&#x5F53;&#x524D;&#x7684;<em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em>&#x521B;&#x5EFA;&#x65B0;&#x7684;<em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em>&#xFF0C;&#x5E76;&#x901A;&#x8FC7;<code>parentCtx</code>&#x6307;&#x5411;&#x539F;&#x6765;&#x7684;<em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em>&#xFF1B;</li>
<li>&#x89E3;&#x6790;&#x8FC7;&#x7A0B;&#x4E2D;<code>v-scope</code>&#x5C31;&#x4F1A;&#x57FA;&#x4E8E;&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;&#x6784;&#x5EFA;&#x65B0;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x590D;&#x5236;&#x5F53;&#x524D;<em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em>&#x7EC4;&#x6210;&#x4E00;&#x4E2A;&#x65B0;&#x7684;<em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em>&#x7528;&#x4E8E;&#x5B50;&#x8282;&#x70B9;&#x7684;&#x89E3;&#x6790;&#x548C;&#x6E32;&#x67D3;&#xFF0C;&#x4F46;&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;&#x5F53;&#x524D;&#x5757;&#x5BF9;&#x8C61;&#x6307;&#x5411;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x3002;</li>
</ul>
<p>&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x9010;&#x4E00;&#x7406;&#x89E3;&#x3002;</p>
<h3 id="&#x4F5C;&#x7528;&#x57DF;scope"><a name="&#x4F5C;&#x7528;&#x57DF;scope" class="anchor-navigation-ex-anchor" href="#&#x4F5C;&#x7528;&#x57DF;scope"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.1. &#x4F5C;&#x7528;&#x57DF;(scope)</h3>
<p>&#x8FD9;&#x91CC;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#x548C;&#x6211;&#x4EEC;&#x7F16;&#x5199;JavaScript&#x65F6;&#x8BF4;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#x662F;&#x4E00;&#x81F4;&#x7684;&#xFF0C;&#x4F5C;&#x7528;&#x662F;&#x9650;&#x5B9A;&#x51FD;&#x6570;&#x548C;&#x53D8;&#x91CF;&#x7684;&#x53EF;&#x7528;&#x8303;&#x56F4;&#xFF0C;&#x51CF;&#x5C11;&#x547D;&#x540D;&#x51B2;&#x7A81;&#x3002;
&#x5177;&#x6709;&#x5982;&#x4E0B;&#x7279;&#x70B9;&#xFF1A;</p>
<ol>
<li>&#x4F5C;&#x7528;&#x57DF;&#x4E4B;&#x95F4;&#x5B58;&#x5728;&#x7236;&#x5B50;&#x5173;&#x7CFB;&#x548C;&#x5144;&#x5F1F;&#x5173;&#x7CFB;&#xFF0C;&#x6574;&#x4F53;&#x6784;&#x6210;&#x4E00;&#x9897;&#x4F5C;&#x7528;&#x57DF;&#x6811;&#xFF1B;</li>
<li>&#x5B50;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x53D8;&#x91CF;&#x6216;&#x5C5E;&#x6027;&#x53EF;&#x8986;&#x76D6;&#x7956;&#x5148;&#x4F5C;&#x7528;&#x57DF;&#x540C;&#x540D;&#x53D8;&#x91CF;&#x6216;&#x5C5E;&#x6027;&#x7684;&#x8BBF;&#x95EE;&#x6027;&#xFF1B;</li>
<li>&#x82E5;&#x5BF9;&#x4EC5;&#x7956;&#x5148;&#x4F5C;&#x7528;&#x57DF;&#x5B58;&#x5728;&#x7684;&#x53D8;&#x91CF;&#x6216;&#x5C5E;&#x6027;&#x8D4B;&#x503C;&#xFF0C;&#x5C06;&#x8D4B;&#x503C;&#x7ED9;&#x7956;&#x5148;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x53D8;&#x91CF;&#x6216;&#x5C5E;&#x6027;&#x3002;</li>
</ol>
<pre><code class="lang-js"><span class="hljs-comment">// &#x5168;&#x5C40;&#x4F5C;&#x7528;&#x57DF;</span>
<span class="hljs-keyword">var</span> globalVariable = <span class="hljs-string">&apos;hello&apos;</span>
<span class="hljs-keyword">var</span> message1 = <span class="hljs-string">&apos;there&apos;</span>
<span class="hljs-keyword">var</span> message2 = <span class="hljs-string">&apos;bye&apos;</span>

(() =&gt; {
  <span class="hljs-comment">// &#x5C40;&#x90E8;&#x4F5C;&#x7528;&#x57DF;A</span>
  <span class="hljs-keyword">let</span> message1 = <span class="hljs-string">&apos;&#x5C40;&#x90E8;&#x4F5C;&#x7528;&#x57DF;A&apos;</span>
  message2 = <span class="hljs-string">&apos;see you&apos;</span>
  <span class="hljs-built_in">console</span>.log(globalVariable, message1, message2)
})()
<span class="hljs-comment">// &#x56DE;&#x663E;&#xFF1A;hello &#x5C40;&#x90E8;&#x4F5C;&#x7528;&#x57DF;A see you</span>

(() =&gt; {
  <span class="hljs-comment">// &#x5C40;&#x90E8;&#x4F5C;&#x7528;&#x57DF;B</span>
  <span class="hljs-built_in">console</span>.log(globalVariable, message1, message2)
})()
<span class="hljs-comment">// &#x56DE;&#x663E;&#xFF1A;hello there see you</span>
</code></pre>
<p>&#x800C;&#x4E14;&#x4F5C;&#x7528;&#x57DF;&#x662F;&#x4F9D;&#x9644;&#x4E0A;&#x4E0B;&#x6587;&#x5B58;&#x5728;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x521B;&#x5EFA;&#x548C;&#x9500;&#x6BC1;&#x81EA;&#x7136;&#x800C;&#x7136;&#x90FD;&#x4F4D;&#x4E8E;&#x4E0A;&#x4E0B;&#x6587;&#x7684;&#x5B9E;&#x73B0;&#x4E2D;(<code>./src/context.ts</code>)&#x3002;
&#x53E6;&#x5916;&#xFF0C;petite-vue&#x4E2D;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#x5E76;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x666E;&#x901A;&#x7684;JavaScript&#x5BF9;&#x8C61;&#xFF0C;&#x800C;&#x662F;&#x4E00;&#x4E2A;&#x7ECF;&#x8FC7;<code>@vue/reactivity</code>&#x5904;&#x7406;&#x7684;&#x54CD;&#x5E94;&#x5F0F;&#x5BF9;&#x8C61;&#xFF0C;&#x76EE;&#x7684;&#x662F;&#x4E00;&#x65E6;&#x4F5C;&#x7528;&#x57DF;&#x6210;&#x5458;&#x88AB;&#x4FEE;&#x6539;&#xFF0C;&#x5219;&#x89E6;&#x53D1;&#x76F8;&#x5173;&#x526F;&#x4F5C;&#x7528;&#x51FD;&#x6570;&#x6267;&#x884C;&#xFF0C;&#x4ECE;&#x800C;&#x91CD;&#x65B0;&#x6E32;&#x67D3;&#x754C;&#x9762;&#x3002;</p>
<h3 id="&#x5757;&#x5BF9;&#x8C61;block"><a name="&#x5757;&#x5BF9;&#x8C61;block" class="anchor-navigation-ex-anchor" href="#&#x5757;&#x5BF9;&#x8C61;block"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.2. &#x5757;&#x5BF9;&#x8C61;(block)</h3>
<p><em>&#x4F5C;&#x7528;&#x57DF;(scope)</em>&#x662F;&#x7528;&#x4E8E;&#x7BA1;&#x7406;JavaScript&#x7684;&#x53D8;&#x91CF;&#x548C;&#x51FD;&#x6570;&#x53EF;&#x7528;&#x8303;&#x56F4;&#xFF0C;&#x800C;<em>&#x5757;&#x5BF9;&#x8C61;(block)</em>&#x5219;&#x7528;&#x4E8E;&#x7BA1;&#x7406;DOM&#x5BF9;&#x8C61;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-comment">// &#x6587;&#x4EF6; ./src/block.ts</span>

<span class="hljs-comment">// &#x57FA;&#x4E8E;&#x793A;&#x4F8B;&#xFF0C;&#x6211;&#x5BF9;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x4E86;&#x5220;&#x51CF;</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> Block {
  template: Element | DocumentFragment <span class="hljs-comment">// &#x4E0D;&#x662F;&#x6307;&#x5411;$template&#xFF0C;&#x800C;&#x662F;&#x5F53;&#x524D;&#x89E3;&#x6790;&#x7684;&#x6A21;&#x677F;&#x5143;&#x7D20;</span>
  ctx: Context <span class="hljs-comment">// &#x6709;&#x5757;&#x5BF9;&#x8C61;&#x521B;&#x5EFA;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;</span>
  parentCtx?: Context <span class="hljs-comment">// &#x5F53;&#x524D;&#x5757;&#x5BF9;&#x8C61;&#x6240;&#x5C5E;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;&#xFF0C;&#x6839;&#x5757;&#x5BF9;&#x8C61;&#x6CA1;&#x6709;&#x5F52;&#x5C5E;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;</span>

  <span class="hljs-comment">// &#x57FA;&#x4E8E;&#x4E0A;&#x8FF0;&#x4F8B;&#x5B50;&#x6CA1;&#x6709;&#x91C7;&#x7528;&lt;template&gt;&#x5143;&#x7D20;&#xFF0C;&#x5E76;&#x4E14;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x4E0D;&#x5305;&#x542B;&#x4EFB;&#x4F55;UI&#x72B6;&#x6001;&#xFF0C;&#x56E0;&#x6B64;&#x6211;&#x5BF9;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x4E86;&#x7B80;&#x5316;</span>
  construct(template: Element, parentCtx: Context, isRoot = <span class="hljs-literal">false</span>) {
    <span class="hljs-keyword">if</span> (isRoot) {
      <span class="hljs-comment">// &#x5BF9;&#x4E8E;&#x6839;&#x5757;&#x5BF9;&#x8C61;&#x76F4;&#x63A5;&#x4EE5;&#x6302;&#x8F7D;&#x70B9;&#x5143;&#x7D20;&#x4F5C;&#x4E3A;&#x6A21;&#x677F;&#x5143;&#x7D20;</span>
      <span class="hljs-keyword">this</span>.template = template
    }
    <span class="hljs-keyword">if</span> (isRoot) {
      <span class="hljs-keyword">this</span>.ctx = parentCtx
    }

    <span class="hljs-comment">// &#x91C7;&#x7528;&#x6DF1;&#x5EA6;&#x4F18;&#x5148;&#x7B56;&#x7565;&#x89E3;&#x6790;&#x5143;&#x7D20;(&#x89E3;&#x6790;&#x8FC7;&#x7A0B;&#x4F1A;&#x5411;&#x5F02;&#x6B65;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x538B;&#x5165;&#x6E32;&#x67D3;&#x4EFB;&#x52A1;)</span>
    walk(<span class="hljs-keyword">this</span>.template, <span class="hljs-keyword">this</span>.ctx)
  }
}
</code></pre>
<pre><code class="lang-ts"><span class="hljs-comment">// &#x6587;&#x4EF6; ./src/walk.ts</span>

<span class="hljs-comment">// &#x57FA;&#x4E8E;&#x4E0A;&#x8FF0;&#x4F8B;&#x5B50;&#x4E3A;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x4E0D;&#x5305;&#x542B;&#x4EFB;&#x4F55;UI&#x72B6;&#x6001;&#xFF0C;&#x56E0;&#x6B64;&#x6211;&#x5BF9;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x4E86;&#x7B80;&#x5316;</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> walk = (node: Node, ctx: Context): ChildNode | <span class="hljs-literal">null</span> | <span class="hljs-built_in">void</span> =&gt; {
  <span class="hljs-keyword">const</span> <span class="hljs-keyword">type</span>= node.nodeType
  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">type</span> === <span class="hljs-number">1</span>) {
    <span class="hljs-comment">// node&#x4E3A;Element&#x7C7B;&#x578B;</span>
    <span class="hljs-keyword">const</span> el = node as Element

    <span class="hljs-keyword">let</span> exp: <span class="hljs-built_in">string</span> | <span class="hljs-literal">null</span>
    <span class="hljs-keyword">if</span> ((exp = checkAttr(el, <span class="hljs-string">&apos;v-scope&apos;</span>)) || exp === <span class="hljs-string">&apos;&apos;</span>) {
      <span class="hljs-comment">// &#x5143;&#x7D20;&#x5E26;`v-scope`&#x5219;&#x8BA1;&#x7B97;&#x51FA;&#x6700;&#x65B0;&#x7684;&#x4F5C;&#x7528;&#x5BF9;&#x8C61;&#x3002;&#x82E5;`v-scope`&#x7684;&#x503C;&#x4E3A;&#x7A7A;&#xFF0C;&#x5219;&#x6700;&#x65B0;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;&#x4E3A;&#x7A7A;&#x5BF9;&#x8C61;</span>
      <span class="hljs-keyword">const</span> scope = exp ? evaluate(ctx.scope, exp) : {}
      <span class="hljs-comment">// &#x66F4;&#x65B0;&#x5F53;&#x524D;&#x4E0A;&#x4E0B;&#x6587;&#x7684;&#x4F5C;&#x7528;&#x57DF;</span>
      ctx = createScopedContext(ctx, scope)
      <span class="hljs-comment">// &#x82E5;&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#x5B58;&#x5728;`$template`&#x6E32;&#x67D3;&#x5230;DOM&#x6811;&#x4E0A;&#x4F5C;&#x4E3A;&#x5728;&#x7EBF;&#x6A21;&#x677F;&#xFF0C;&#x540E;&#x7EED;&#x4F1A;&#x9012;&#x5F52;&#x89E3;&#x6790;&#x5904;&#x7406;</span>
      <span class="hljs-comment">// &#x6CE8;&#x610F;&#xFF1A;&#x8FD9;&#x91CC;&#x4E0D;&#x4F1A;&#x8BFB;&#x53D6;&#x7236;&#x4F5C;&#x7528;&#x57DF;&#x7684;`$template`&#x5C5E;&#x6027;&#xFF0C;&#x5FC5;&#x987B;&#x662F;&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#x7684;</span>
      <span class="hljs-keyword">if</span> (scope.$template) {
        resolveTemplate(el, scope.$template)
      }
    }

    walkChildren(el, ctx)
  }
}

<span class="hljs-comment">// &#x9996;&#x5148;&#x89E3;&#x6790;&#x7B2C;&#x4E00;&#x4E2A;&#x5B69;&#x5B50;&#x8282;&#x70B9;&#xFF0C;&#x82E5;&#x6CA1;&#x6709;&#x5B69;&#x5B50;&#x5219;&#x89E3;&#x6790;&#x5144;&#x5F1F;&#x8282;&#x70B9;</span>
<span class="hljs-keyword">const</span> walkChildren = (node: Element | DocumentFragment, ctx: Context) =&gt; {
  <span class="hljs-keyword">let</span> child = node.firstChild
  <span class="hljs-keyword">while</span> (child) {
    child = walk(child, ctx) || child.nextSibling
  }
}

<span class="hljs-comment">// &#x57FA;&#x4E8E;&#x4E0A;&#x8FF0;&#x4F8B;&#x5B50;&#x6211;&#x5BF9;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x4E86;&#x7B80;&#x5316;</span>
<span class="hljs-keyword">const</span> resolveTemplate = (el: Element, template: <span class="hljs-built_in">string</span>) =&gt; {
  <span class="hljs-comment">// &#x5F97;&#x76CA;&#x4E8E;Vue&#x91C7;&#x7528;&#x7684;&#x6A21;&#x677F;&#x5B8C;&#x5168;&#x7B26;&#x5408;HTML&#x89C4;&#x8303;&#xFF0C;&#x6240;&#x4EE5;&#x8FD9;&#x4E48;&#x76F4;&#x63A5;&#x7B80;&#x5355;&#x5730;&#x6E32;&#x67D3;&#x4E3A;HTML&#x5143;&#x7D20;&#x540E;&#xFF0C;`@click`&#x548C;`:value`&#x7B49;&#x5C5E;&#x6027;&#x540D;&#x79F0;&#x4F9D;&#x7136;&#x4E0D;&#x4F1A;&#x4E22;&#x5931;</span>
  el.innerHTML = template
}
</code></pre>
<p>&#x4E3A;&#x4E86;&#x66F4;&#x5BB9;&#x6613;&#x9605;&#x8BFB;&#x6211;&#x53C8;&#x5BF9;&#x8868;&#x8FBE;&#x5F0F;&#x8FD0;&#x7B97;&#x7684;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x4E86;&#x7B80;&#x5316;&#xFF08;&#x79FB;&#x9664;&#x5F00;&#x53D1;&#x9636;&#x6BB5;&#x7684;&#x63D0;&#x793A;&#x548C;&#x7F13;&#x5B58;&#x673A;&#x5236;&#xFF09;</p>
<pre><code class="lang-ts"><span class="hljs-comment">// &#x6587;&#x4EF6; ./src/eval.ts</span>

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> evaluate = (scope: <span class="hljs-built_in">any</span>, exp: <span class="hljs-built_in">string</span>, el? Node) =&gt; execute(scope, exp, el)

<span class="hljs-keyword">const</span> execute = (scope: <span class="hljs-built_in">any</span>, exp: <span class="hljs-built_in">string</span>, el? Node) =&gt; {
  <span class="hljs-keyword">const</span> fn = toFunction(exp)
  <span class="hljs-keyword">return</span> fn(scope, el)
}

<span class="hljs-keyword">const</span> toFunction = (exp: <span class="hljs-built_in">string</span>): <span class="hljs-built_in">Function</span> =&gt; {
  <span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Function</span>(<span class="hljs-string">&apos;$data&apos;</span>, <span class="hljs-string">&apos;$el&apos;</span>, <span class="hljs-string">`with($data){return(<span class="hljs-subst">${exp}</span>)}`</span>)
  }
  <span class="hljs-keyword">catch</span>(e) {
    <span class="hljs-keyword">return</span> () =&gt; {}
  }
}
</code></pre>
<h3 id="&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;context"><a name="&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;context" class="anchor-navigation-ex-anchor" href="#&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;context"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.3. &#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</h3>
<p>&#x4E0A;&#x9762;&#x6211;&#x4EEC;&#x4E86;&#x89E3;&#x5230;<em>&#x4F5C;&#x7528;&#x57DF;(scope)</em>&#x662F;&#x7528;&#x4E8E;&#x7BA1;&#x7406;JavaScript&#x7684;&#x53D8;&#x91CF;&#x548C;&#x51FD;&#x6570;&#x53EF;&#x7528;&#x8303;&#x56F4;&#xFF0C;&#x800C;<em>&#x5757;&#x5BF9;&#x8C61;(block)</em>&#x5219;&#x7528;&#x4E8E;&#x7BA1;&#x7406;DOM&#x5BF9;&#x8C61;&#xFF0C;&#x90A3;&#x4E48;<em>&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;(context)</em>&#x5219;&#x662F;&#x8FDE;&#x63A5;<em>&#x4F5C;&#x7528;&#x57DF;(scope)</em>&#x548C;<em>&#x5757;&#x5BF9;&#x8C61;(block)</em>&#x7684;&#x8F7D;&#x4F53;&#xFF0C;&#x4E5F;&#x662F;&#x5C06;&#x591A;&#x4E2A;<em>&#x5757;&#x5BF9;&#x8C61;</em>&#x7EC4;&#x6210;&#x6811;&#x72B6;&#x7ED3;&#x6784;&#x7684;&#x8FDE;&#x63A5;&#x70B9;(<code>[&#x6839;&#x5757;&#x5BF9;&#x8C61;.ctx] -&gt; [&#x6839;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;, &#x6839;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;.blocks] -&gt; [&#x5B50;&#x5757;&#x5BF9;&#x8C61;] -&gt; [&#x5B50;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;]</code>)&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-comment">// &#x6587;&#x4EF6; ./src/context.ts</span>

<span class="hljs-keyword">export</span> <span class="hljs-keyword">interface</span> Context {
  scope: Record&lt;<span class="hljs-built_in">string</span>, <span class="hljs-built_in">any</span>&gt; <span class="hljs-comment">// &#x5F53;&#x524D;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x5E94;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;</span>
  cleanups: (()=&gt;<span class="hljs-built_in">void</span>)[] <span class="hljs-comment">// &#x5F53;&#x524D;&#x4E0A;&#x4E0B;&#x6587;&#x6307;&#x4EE4;&#x7684;&#x6E05;&#x7406;&#x51FD;&#x6570;</span>
  blocks: Block[] <span class="hljs-comment">// &#x5F52;&#x5C5E;&#x4E8E;&#x5F53;&#x524D;&#x4E0A;&#x4E0B;&#x6587;&#x7684;&#x5757;&#x5BF9;&#x8C61;</span>
  effect: <span class="hljs-keyword">typeof</span> rawEffect <span class="hljs-comment">// &#x7C7B;&#x4F3C;&#x4E8E;@vue/reactivity&#x7684;effect&#x65B9;&#x6CD5;&#xFF0C;&#x4F46;&#x53EF;&#x6839;&#x636E;&#x6761;&#x4EF6;&#x9009;&#x62E9;&#x8C03;&#x5EA6;&#x65B9;&#x5F0F;</span>
  effects: ReactiveEffectRunner[] <span class="hljs-comment">// &#x5F53;&#x524D;&#x4E0A;&#x4E0B;&#x6587;&#x6301;&#x6709;&#x526F;&#x4F5C;&#x7528;&#x65B9;&#x6CD5;&#xFF0C;&#x7528;&#x4E8E;&#x4E0A;&#x4E0B;&#x6587;&#x9500;&#x6BC1;&#x65F6;&#x56DE;&#x6536;&#x526F;&#x4F5C;&#x7528;&#x65B9;&#x6CD5;&#x91CA;&#x653E;&#x8D44;&#x6E90;</span>
}

<span class="hljs-comment">/**
 * &#x7531;Block&#x6784;&#x9020;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x521B;&#x5EFA;&#x65B0;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;&#xFF0C;&#x7279;&#x6027;&#x5982;&#x4E0B;&#xFF1A;
 * 1. &#x65B0;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;&#x4F5C;&#x7528;&#x57DF;&#x4E0E;&#x7236;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;&#x4E00;&#x81F4;
 * 2. &#x65B0;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;&#x62E5;&#x6709;&#x5168;&#x65B0;&#x7684;effects&#x3001;blocks&#x548C;cleanups&#x6210;&#x5458;
 * &#x7ED3;&#x8BBA;&#xFF1A;&#x7531;Block&#x6784;&#x9020;&#x51FD;&#x6570;&#x53D1;&#x8D77;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;&#x521B;&#x5EFA;&#xFF0C;&#x4E0D;&#x5F71;&#x54CD;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;&#xFF0C;&#x4F46;&#x8BE5;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;&#x4F1A;&#x72EC;&#x7ACB;&#x7BA1;&#x7406;&#x65D7;&#x4E0B;&#x7684;&#x526F;&#x4F5C;&#x7528;&#x65B9;&#x6CD5;&#x3001;&#x5757;&#x5BF9;&#x8C61;&#x548C;&#x6307;&#x4EE4;
 */</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> createContext = (parent? Context): Context =&gt; {
  <span class="hljs-keyword">const</span> ctx: Context = {
    ...parent,
    scope: parent ? parent.scope : reactive({}), <span class="hljs-comment">// &#x6307;&#x5411;&#x7236;&#x4E0A;&#x4E0B;&#x6587;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;</span>
    effects: [],
    blocks: [],
    cleanups: [],
    effect: fn =&gt; {
      <span class="hljs-comment">// &#x5F53;&#x89E3;&#x6790;&#x9047;&#x5230;`v-once`&#x5C5E;&#x6027;,`inOnce`&#x5373;&#x88AB;&#x8BBE;&#x7F6E;&#x4E3A;`true`&#xFF0C;&#x800C;&#x526F;&#x4F5C;&#x7528;&#x51FD;&#x6570;`fn`&#x5373;&#x76F4;&#x63A5;&#x538B;&#x5165;&#x5F02;&#x6B65;&#x4EFB;&#x52A1;&#x961F;&#x5217;&#x6267;&#x884C;&#x4E00;&#x6B21;&#xFF0C;&#x5373;&#x4F7F;&#x5176;&#x4F9D;&#x8D56;&#x7684;&#x72B6;&#x6001;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x526F;&#x4F5C;&#x7528;&#x51FD;&#x6570;&#x4E5F;&#x4E0D;&#x4F1A;&#x88AB;&#x89E6;&#x53D1;&#x3002;</span>
      <span class="hljs-keyword">if</span> (inOnce) {
        queueJob(fn)
        <span class="hljs-keyword">return</span> fn as <span class="hljs-built_in">any</span>
      }
      <span class="hljs-comment">// &#x751F;&#x6210;&#x72B6;&#x6001;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x65F6;&#x81EA;&#x52A8;&#x89E6;&#x53D1;&#x7684;&#x526F;&#x4F5C;&#x7528;&#x51FD;&#x6570;</span>
      <span class="hljs-keyword">const</span> e: ReactiveEffectRunner = rawEffect(fn, {
        scheduler: () =&gt; queueJob(e)
      })
      ctx.effects.push(e)
      <span class="hljs-keyword">return</span> e
    }
  }
  <span class="hljs-keyword">return</span> ctx
}

<span class="hljs-comment">/**
 * &#x5F53;&#x89E3;&#x6790;&#x65F6;&#x9047;&#x5230;`v-scope`&#x5C5E;&#x6027;&#x5E76;&#x5B58;&#x5728;&#x6709;&#x6548;&#x503C;&#x65F6;&#xFF0C;&#x4FBF;&#x4F1A;&#x8C03;&#x7528;&#x8BE5;&#x65B9;&#x6CD5;&#x57FA;&#x4E8E;&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#x521B;&#x5EFA;&#x65B0;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x590D;&#x5236;&#x5F53;&#x524D;&#x4E0A;&#x4E0B;&#x6587;&#x5C5E;&#x6027;&#x6784;&#x5EFA;&#x65B0;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;&#x7528;&#x4E8E;&#x5B50;&#x8282;&#x70B9;&#x7684;&#x89E3;&#x6790;&#x548C;&#x6E32;&#x67D3;&#x3002;
 */</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> createScopedContext = (ctx: Context, data = {}): Context =&gt; {
  <span class="hljs-keyword">const</span> parentScope = ctx.scope
  <span class="hljs-comment">/* &#x6784;&#x9020;&#x4F5C;&#x7528;&#x57DF;&#x5BF9;&#x8C61;&#x539F;&#x578B;&#x94FE; 
   * &#x6B64;&#x65F6;&#x82E5;&#x5F53;&#x8BBE;&#x7F6E;&#x7684;&#x5C5E;&#x6027;&#x4E0D;&#x5B58;&#x5728;&#x4E8E;&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#xFF0C;&#x5219;&#x4F1A;&#x5728;&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#x521B;&#x5EFA;&#x8BE5;&#x5C5E;&#x6027;&#x5E76;&#x8D4B;&#x503C;&#x3002;
   */</span>
  <span class="hljs-keyword">const</span> mergeScope = <span class="hljs-built_in">Object</span>.create(parentScope)
  <span class="hljs-built_in">Object</span>.defineProperties(mergeScope, <span class="hljs-built_in">Object</span>.getOwnPropertyDescriptors(data))
  <span class="hljs-comment">// &#x6784;&#x9020;ref&#x5BF9;&#x8C61;&#x539F;&#x578B;&#x94FE;</span>
  mergeScope.$ref = <span class="hljs-built_in">Object</span>.create(parentScope.$refs)
  <span class="hljs-comment">// &#x6784;&#x9020;&#x4F5C;&#x7528;&#x57DF;&#x94FE;</span>
  <span class="hljs-keyword">const</span> reactiveProxy = reactive(
    <span class="hljs-keyword">new</span> Proxy(mergeScope, {
      <span class="hljs-keyword">set</span>(target, key, val, receiver) {
        <span class="hljs-comment">// &#x82E5;&#x5F53;&#x8BBE;&#x7F6E;&#x7684;&#x5C5E;&#x6027;&#x4E0D;&#x5B58;&#x5728;&#x4E8E;&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#x5219;&#x5C06;&#x503C;&#x8BBE;&#x7F6E;&#x5230;&#x7236;&#x4F5C;&#x7528;&#x57DF;&#x4E0A;&#xFF0C;&#x7531;&#x4E8E;&#x7236;&#x4F5C;&#x7528;&#x57DF;&#x4EE5;&#x540C;&#x6837;&#x65B9;&#x5F0F;&#x521B;&#x5EFA;&#xFF0C;&#x56E0;&#x6B64;&#x9012;&#x5F52;&#x627E;&#x5230;&#x62E5;&#x6709;&#x8BE5;&#x5C5E;&#x6027;&#x7684;&#x7956;&#x5148;&#x4F5C;&#x7528;&#x57DF;&#x5E76;&#x8D4B;&#x503C;</span>
        <span class="hljs-keyword">if</span> (receiver === reactiveProxy &amp;&amp; !target.hasOwnProperty(key)) {
          <span class="hljs-keyword">return</span> Reflect.set(parentScope, key, val)
        }
        <span class="hljs-keyword">return</span> Reflect.set(target, key, val, receiver)
      }
    })
  )

  <span class="hljs-comment">/* &#x5C06;scope&#x7684;&#x51FD;&#x6570;&#x6210;&#x5458;&#x7684;this&#x5747;&#x7ED1;&#x5B9A;&#x4E3A;scope&#x3002;
   * &#x82E5;&#x91C7;&#x7528;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x8D4B;&#x503C;&#x7ED9;&#x51FD;&#x6570;&#x6210;&#x5458;&#xFF0C;&#x5219;&#x4E0A;&#x8FF0;&#x64CD;&#x4F5C;&#x5BF9;&#x8BE5;&#x51FD;&#x6570;&#x6210;&#x5458;&#x65E0;&#x6548;&#x3002;
   */</span>
  bindContextMethods(reactiveProxy)
  <span class="hljs-keyword">return</span> {
    ...ctx,
    scope: reactiveProxy
  }
}
</code></pre>
<h2 id="&#x4EBA;&#x8089;&#x5355;&#x6B65;&#x8C03;&#x8BD5;"><a name="&#x4EBA;&#x8089;&#x5355;&#x6B65;&#x8C03;&#x8BD5;" class="anchor-navigation-ex-anchor" href="#&#x4EBA;&#x8089;&#x5355;&#x6B65;&#x8C03;&#x8BD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. &#x4EBA;&#x8089;&#x5355;&#x6B65;&#x8C03;&#x8BD5;</h2>
<ol>
<li>&#x8C03;&#x7528;<code>createApp</code>&#x6839;&#x636E;&#x5165;&#x53C2;&#x751F;&#x6210;&#x5168;&#x5C40;&#x4F5C;&#x7528;&#x57DF;<code>rootScope</code>&#xFF0C;&#x521B;&#x5EFA;&#x6839;&#x4E0A;&#x4E0B;&#x6587;<code>rootCtx</code>&#xFF1B;</li>
<li>&#x8C03;&#x7528;<code>mount</code>&#x4E3A;<code>&lt;div v-scope=&quot;App&quot;&gt;&lt;/div&gt;</code>&#x6784;&#x5EFA;&#x6839;&#x5757;&#x5BF9;&#x8C61;<code>rootBlock</code>&#xFF0C;&#x5E76;&#x5C06;&#x5176;&#x4F5C;&#x4E3A;&#x6A21;&#x677F;&#x6267;&#x884C;&#x89E3;&#x6790;&#x5904;&#x7406;&#xFF1B;</li>
<li>&#x89E3;&#x6790;&#x65F6;&#x8BC6;&#x522B;&#x5230;<code>v-scope</code>&#x5C5E;&#x6027;&#xFF0C;&#x4EE5;&#x5168;&#x5C40;&#x4F5C;&#x7528;&#x57DF;<code>rootScope</code>&#x4E3A;&#x57FA;&#x7840;&#x8FD0;&#x7B97;&#x5F97;&#x5230;&#x5C40;&#x90E8;&#x4F5C;&#x7528;&#x57DF;<code>scope</code>&#xFF0C;&#x5E76;&#x4EE5;&#x6839;&#x4E0A;&#x4E0B;&#x6587;<code>rootCtx</code>&#x4E3A;&#x84DD;&#x672C;&#x4E00;&#x540C;&#x6784;&#x5EFA;&#x65B0;&#x7684;&#x4E0A;&#x4E0B;&#x6587;<code>ctx</code>&#xFF0C;&#x7528;&#x4E8E;&#x5B50;&#x8282;&#x70B9;&#x7684;&#x89E3;&#x6790;&#x548C;&#x6E32;&#x67D3;&#xFF1B;</li>
<li>&#x83B7;&#x53D6;<code>$template</code>&#x5C5E;&#x6027;&#x503C;&#x5E76;&#x751F;&#x6210;HTML&#x5143;&#x7D20;&#xFF1B;</li>
<li>&#x6DF1;&#x5EA6;&#x4F18;&#x5148;&#x904D;&#x5386;&#x89E3;&#x6790;&#x5B50;&#x8282;&#x70B9;&#x3002;</li>
</ol>
<h2 id="&#x5C0F;&#x7ED3;"><a name="&#x5C0F;&#x7ED3;" class="anchor-navigation-ex-anchor" href="#&#x5C0F;&#x7ED3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. &#x5C0F;&#x7ED3;</h2>
<p>&#x901A;&#x8FC7;&#x7B80;&#x5355;&#x7684;&#x4F8B;&#x5B50;&#x6211;&#x4EEC;&#x5BF9;petite-vue&#x7684;&#x89E3;&#x6790;&#x3001;&#x8C03;&#x5EA6;&#x548C;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;&#x6709;&#x4E86;&#x4E00;&#x5B9A;&#x7A0B;&#x5EA6;&#x7684;&#x4E86;&#x89E3;&#xFF0C;&#x4E0B;&#x4E00;&#x7BC7;&#x6211;&#x4EEC;&#x5C06;&#x518D;&#x6B21;&#x901A;&#x8FC7;&#x9759;&#x6001;&#x89C6;&#x56FE;&#x770B;&#x770B;<code>v-if</code>&#x548C;<code>v-for</code>&#x662F;&#x5982;&#x4F55;&#x6839;&#x636E;&#x72B6;&#x6001;&#x6539;&#x53D8;DOM&#x6811;&#x7ED3;&#x6784;&#x7684;&#x3002;
&#x53E6;&#x5916;&#xFF0C;&#x53EF;&#x80FD;&#x6709;&#x670B;&#x53CB;&#x4F1A;&#x6709;&#x5982;&#x4E0B;&#x7591;&#x95EE;</p>
<ol>
<li>Proxy&#x7684;receiver&#x662F;&#x4EC0;&#x4E48;&#xFF1F;</li>
<li><code>new Function</code>&#x548C;<code>eval</code>&#x7684;&#x533A;&#x522B;&#xFF1F;</li>
</ol>
<p>&#x7EE7;&#x7EED;&#x770B;&#x4E0B;&#x53BB;&#x5427;:D</p>
<script type="text/javascript">
  /**
   * Donation
   */
  function showQR(){
    var rewardButton = document.getElementById('rewardButton')
    var qr = document.getElementById('QR')
    if (rewardButton) {
      rewardButton.style.display = 'none'
    }
    if (qr) {
      qr.style.display = 'block'
    }
  }
  setInterval(showQR, 1000)

  /**
   * Baidu analysis
   */
  var _hmt = _hmt || [];
  (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?8bca1e3aa362a7f85dbe8304cff65225";
    var s = document.getElementsByTagName("script")[0]; 
    s.parentNode.insertBefore(hm, s);
  })();
</script>


<footer class="page-footer"><span class="copyright">Copyright &#xA9; fsjohnhuang 2022 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">File Modify: 
2022-04-26 09:46:24
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="0_intro.html" class="navigation navigation-prev " aria-label="Previous page: 章节介绍">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="2_initial_rendering_and_rerendering_for_v-if.html" class="navigation navigation-next " aria-label="Next page: 条件v-if的首次渲染和重新渲染">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"从静态视图首次渲染开始","level":"2.2","depth":1,"next":{"title":"条件v-if的首次渲染和重新渲染","level":"2.3","depth":1,"path":"1_online_rendering/2_initial_rendering_and_rerendering_for_v-if.md","ref":"1_online_rendering/2_initial_rendering_and_rerendering_for_v-if.md","articles":[]},"previous":{"title":"章节介绍","level":"2.1","depth":1,"path":"1_online_rendering/0_intro.md","ref":"1_online_rendering/0_intro.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","-sharing","theme-comscore","search-pro","code","back-to-top-button","tbfed-pagefooter","chapter-fold","expandable-chapters","splitter","anchor-navigation-ex","donate","sharing-plus","baidu"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy fsjohnhuang 2022"},"chapter-fold":{},"splitter":{},"search-pro":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"code":{"copyButtons":true},"donate":{"alipay":"","alipayText":"支付宝打赏","button":"赞赏","title":"","wechat":"/petite-vue-source-reading/images/wechat.jpg","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":false,"showLevel":true},"theme-comscore":{},"back-to-top-button":{},"baidu":{"token":"8bca1e3aa362a7f85dbe8304cff65225"},"sharing":{"qq":false,"all":["qq","qzone","weibo","whatsapp","twitter","facebook","line"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"^_^肥仔John","lang":"zh-cn","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"isbn":"","variables":{},"title":"petite-vue源码剖析","gitbook":"*","description":""},"file":{"path":"1_online_rendering/1_start_from_static_view.md","mtime":"2022-04-26T01:46:24.920Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-05-05T01:20:11.998Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-baidu/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

